package com.cdc.sboot.json;

import java.util.Date;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class JsonController {
	/**
	 * Springbootm默认使用jackson解析json
	 * 
	 * @return
	 */
	@RequestMapping("/getStudent")
	public Student getStudent() {
		Student student = new Student();
		student.setId("1");
		student.setName("张三");
		student.setBirthdate(new Date());
		return student;
	}
	/**
	 * 上传json数据 并返回json数据
	 * @param student
	 * @return
	 */
	@RequestMapping(value = "/getJson", method = RequestMethod.POST)
	@ResponseBody
	public Student getJson(@RequestBody Student student) {
		student.setId("1=返回");
		student.setName("张三=返回");
		student.setBirthdate(new Date());
		return student;
	}

}
